﻿package com.tudou.ad.components
{
    import com.tudou.skin.*;
    import com.tudou.skin.common.button.*;
    import com.tudou.skin.common.events.*;
    import com.tudou.utils.*;
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;

    public class AdVideoControlPanel extends AdVideoControlPanelBase
    {
        protected var bg:Sprite;

        public function AdVideoControlPanel()
        {
            var _loc_1:int = 0;
            _loc_1 = 14;
            bg = new AdCountDownBgMC();
            addChild(bg);
            timeTip = TextFieldUtil.getTextField();
            timeTip.defaultTextFormat = new TextFormat("Arial", 12, 16777215);
            timeTip.antiAliasType = AntiAliasType.ADVANCED;
            timeTip.y = _loc_1;
            timeTip.text = "";
            addChild(timeTip);
            adVolume = new BaseButton();
            adVolume.y = _loc_1;
            adVolume.addStateButton(new AdCloseSoundBTN());
            adVolume.addStateButton(new AdOpenSoundBTN());
            addChild(adVolume);
            skipBtn = new AdSkipBTN();
            skipBtn.y = _loc_1;
            addChild(skipBtn);
            adVolume.activeIndex = 0;
            adVolume.clickContainer = true;
            skipBtn.visible = false;
            adVolume.addEventListener(ButtonEvent.CLICK, volumeHlr);
            skipBtn.addEventListener(MouseEvent.CLICK, skipHlr);
            return;
        }// end function

        override public function clear() : void
        {
            if (adVolume)
            {
                adVolume.removeEventListener(ButtonEvent.CLICK, volumeHlr);
            }
            if (skipBtn)
            {
                skipBtn.removeEventListener(ButtonEvent.CLICK, skipHlr);
            }
            while (this.numChildren > 0)
            {
                
                this.removeChildAt(0);
            }
            timeTip = null;
            adVolume = null;
            skipBtn = null;
            return;
        }// end function

        override public function set width(param1:Number) : void
        {
            bg.x = int((param1 - bg.width) / 2);
            timeTip.x = int((param1 - timeTip.width) / 2);
            adVolume.x = bg.x + bg.width - adVolume.width - 6;
            skipBtn.x = bg.x + 6;
            return;
        }// end function

    }
}
